<template>
	<el-drawer title="项目详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form :model="form">
					<el-form-item label="项目名称" prop="title">{{form.title}}</el-form-item>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="项目类型" prop="projectType">{{form.projectTypeName}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="项目编号" prop="projectCode">{{form.projectCode}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="项目负责人" prop="chargeUser">{{form.chargeUserName}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="预算总费用" prop="totalCost">{{form.totalCost}}/万元</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="24">
							<el-form-item label="项目参与人" prop="joinUserName">{{form.joinUserName}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="开始时间" prop="beginTime">{{form.beginTime}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="结束时间" prop="endTime">{{form.endTime}}</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="所属账套" prop="budgetAccount">{{form.budgetAccountName}}</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="资金出处" prop="cashFrom">{{form.cashFrom}}</el-form-item>
						</el-col>
					</el-row>
					<el-form-item label="项目说明"><div v-html="form.remark"></div></el-form-item>
					<el-form-item label="项目附件" prop="attachId">
						<attach-menu :attachIds="form.attachId" :roleFlag="3" :preview="true"></attach-menu>
					</el-form-item>
				</el-form>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			loading: false,
			form: {
				projectId:'',
				title: '',
				projectTypeName: '',
				projectCode: '',
				chargeUserName:'',
				totalCost:0,
				joinUserName:'',
				beginTime:'',
				endTime:'',
				budgetAccountName:'',
				cashFrom:'',
				remark:'',
				attachId:''
			},
			model:"rece",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		//表单注入数据
		setData(data){
			this.form.projectId = data.projectId
			this.form.title = data.title
			this.form.projectTypeName = data.projectTypeName
			this.form.projectCode = data.projectCode
			this.form.chargeUserName = data.chargeUserName
			this.form.totalCost = data.totalCost
			this.form.joinUser = data.joinUser
			this.form.beginTime = data.beginTime
			this.form.endTime = data.endTime
			this.form.budgetAccountName = data.budgetAccountName
			this.form.cashFrom = data.cashFrom
			this.form.remark = data.remark
			this.form.attachId = data.attachId
			this.getUserListByAccountIds(data.joinUser);
		},
		async getUserListByAccountIds(accountIds){
			let res = await this.$API.system.user.getUserListByAccountIds.get({accountIds:accountIds});
			if(res.code==200)
			{
				let arr=[];
				if(res.data!=undefined)
				{
					res.data.forEach(item=>{
						arr.push(item.userName);
					})
				}
				this.form.joinUserName=arr.join(",");
			}
		}
	}
}
</script>

<style>
</style>
